package com.loc;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.text.TextUtils;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClientOption;
import java.util.ArrayList;

/* compiled from: Aps.java */
/* loaded from: classes2.dex */
public final class er {
    static int A = -1;
    public static String[] D = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_FINE_LOCATION"};
    public static String E = "android.permission.ACCESS_BACKGROUND_LOCATION";
    private static boolean K = false;
    private static volatile boolean Q = false;
    boolean F;
    private Handler N;
    private fd O;
    private String P;
    private es R;
    Context a = null;
    ConnectivityManager b = null;
    fh c = null;
    fb d = null;
    fj e = null;
    fq f = null;
    ArrayList<eg> g = new ArrayList<>();
    a h = null;
    AMapLocationClientOption i = new AMapLocationClientOption();
    ew j = null;
    long k = 0;
    private int I = 0;
    fr l = null;
    boolean m = false;
    private String J = null;
    fo n = null;
    StringBuilder o = new StringBuilder();
    boolean p = true;
    boolean q = true;
    AMapLocationClientOption.GeoLanguage r = AMapLocationClientOption.GeoLanguage.DEFAULT;
    boolean s = true;
    boolean t = false;
    private String L = null;
    StringBuilder u = null;
    boolean v = false;
    public boolean w = false;
    int x = 12;
    private boolean M = true;
    ey y = null;
    boolean z = false;
    ev B = null;
    String C = null;
    IntentFilter G = null;
    LocationManager H = null;

    /* compiled from: Aps.java */
    /* renamed from: com.loc.er$1 */
    /* loaded from: classes2.dex */
    public static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] a;

        static {
            int[] iArr = new int[AMapLocationClientOption.GeoLanguage.values().length];
            a = iArr;
            try {
                iArr[AMapLocationClientOption.GeoLanguage.DEFAULT.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[AMapLocationClientOption.GeoLanguage.ZH.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[AMapLocationClientOption.GeoLanguage.EN.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    /* compiled from: Aps.java */
    /* loaded from: classes2.dex */
    public class a extends BroadcastReceiver {
        a() {
            er.this = r1;
        }

        @Override // android.content.BroadcastReceiver
        public final void onReceive(Context context, Intent intent) {
            if (context == null || intent == null) {
                return;
            }
            try {
                String action = intent.getAction();
                if (TextUtils.isEmpty(action)) {
                    return;
                }
                if (!action.equals("android.net.wifi.SCAN_RESULTS")) {
                    if (!action.equals("android.net.wifi.WIFI_STATE_CHANGED") || er.this.c == null) {
                        return;
                    }
                    er.this.c.j();
                    return;
                }
                if (er.this.c != null) {
                    er.this.c.i();
                }
                try {
                    if (intent.getExtras() == null || !intent.getExtras().getBoolean("resultsUpdated", true) || er.this.c == null) {
                        return;
                    }
                    er.this.c.h();
                } catch (Throwable unused) {
                }
            } catch (Throwable th) {
                ft.a(th, "Aps", "onReceive");
            }
        }
    }

    public er(boolean z) {
        this.F = false;
        this.F = z;
    }

    private static ew a(int i, String str) {
        ew ewVar = new ew("");
        ewVar.setErrorCode(i);
        ewVar.setLocationDetail(str);
        if (i == 15) {
            fz.a((String) null, 2151);
        }
        return ewVar;
    }

    private ew a(ew ewVar, bu buVar, eq eqVar) {
        if (buVar != null) {
            try {
                if (buVar.a != null && buVar.a.length != 0) {
                    fq fqVar = new fq();
                    String str = new String(buVar.a, "UTF-8");
                    if (str.contains("\"status\":\"0\"")) {
                        ew a2 = fqVar.a(str, this.a, buVar, eqVar);
                        a2.h(this.u.toString());
                        return a2;
                    } else if (str.contains("</body></html>")) {
                        ewVar.setErrorCode(5);
                        fh fhVar = this.c;
                        if (fhVar == null || !fhVar.a(this.b)) {
                            eqVar.f("#0502");
                            this.o.append("请求可能被劫持了#0502");
                            fz.a((String) null, 2052);
                        } else {
                            eqVar.f("#0501");
                            this.o.append("您连接的是一个需要登录的网络，请确认已经登入网络#0501");
                            fz.a((String) null, 2051);
                        }
                        ewVar.setLocationDetail(this.o.toString());
                        return ewVar;
                    } else {
                        return null;
                    }
                }
            } catch (Throwable th) {
                ewVar.setErrorCode(4);
                ft.a(th, "Aps", "checkResponseEntity");
                eqVar.f("#0403");
                StringBuilder sb = this.o;
                sb.append("check response exception ex is" + th.getMessage() + "#0403");
                ewVar.setLocationDetail(this.o.toString());
                return ewVar;
            }
        }
        ewVar.setErrorCode(4);
        this.o.append("网络异常,请求异常#0403");
        eqVar.f("#0403");
        ewVar.h(this.u.toString());
        ewVar.setLocationDetail(this.o.toString());
        if (buVar != null) {
            fz.a(buVar.d, 2041);
        }
        return ewVar;
    }

    private StringBuilder a(StringBuilder sb) {
        if (sb == null) {
            sb = new StringBuilder(700);
        } else {
            sb.delete(0, sb.length());
        }
        fb fbVar = this.d;
        if (fbVar != null && this.c != null) {
            sb.append(fbVar.m());
            sb.append(this.c.o());
        }
        return sb;
    }

    private boolean a(long j) {
        if (!this.M) {
            this.M = true;
            return false;
        }
        if (gb.b() - j < 800) {
            if ((gb.a(this.j) ? gb.a() - this.j.getTime() : 0L) <= 10000) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:152:0x0106 A[Catch: all -> 0x01fa, TRY_LEAVE, TryCatch #1 {all -> 0x01fa, blocks: (B:116:0x0052, B:118:0x007b, B:122:0x0086, B:124:0x008e, B:127:0x0096, B:128:0x0098, B:130:0x009e, B:131:0x00a8, B:135:0x00b1, B:137:0x00c4, B:139:0x00c8, B:140:0x00d2, B:143:0x00e8, B:145:0x00ee, B:147:0x00f2, B:150:0x0102, B:152:0x0106, B:148:0x00f9, B:149:0x00ff), top: B:208:0x0052 }] */
    /* JADX WARN: Removed duplicated region for block: B:155:0x010e  */
    /* JADX WARN: Removed duplicated region for block: B:159:0x0137  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x013e A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:163:0x013f  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private com.loc.ew b(boolean r12, com.loc.eq r13) {
        /*
            Method dump skipped, instructions count: 753
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.loc.er.b(boolean, com.loc.eq):com.loc.ew");
    }

    private void b(Context context) {
        try {
            if (context.checkCallingOrSelfPermission(x.c("EYW5kcm9pZC5wZXJtaXNzaW9uLldSSVRFX1NFQ1VSRV9TRVRUSU5HUw==")) == 0) {
                this.m = true;
            }
        } catch (Throwable unused) {
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:237:0x01c6, code lost:
        if (com.loc.gb.f(r16.a) == false) goto L76;
     */
    /* JADX WARN: Code restructure failed: missing block: B:240:0x01d6, code lost:
        if (com.loc.gb.f(r16.a) == false) goto L76;
     */
    /* JADX WARN: Code restructure failed: missing block: B:241:0x01d8, code lost:
        r16.o.append("或后台运行没有后台定位权限");
     */
    /* JADX WARN: Code restructure failed: missing block: B:242:0x01dd, code lost:
        r1 = r16.o;
     */
    /* JADX WARN: Code restructure failed: missing block: B:253:0x0259, code lost:
        if (r6 == false) goto L102;
     */
    /* JADX WARN: Code restructure failed: missing block: B:258:0x0292, code lost:
        if (r6 == false) goto L102;
     */
    /* JADX WARN: Removed duplicated region for block: B:304:0x0376  */
    /* JADX WARN: Removed duplicated region for block: B:310:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private java.lang.String c(com.loc.eq r17) {
        /*
            Method dump skipped, instructions count: 927
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.loc.er.c(com.loc.eq):java.lang.String");
    }

    private static void c(ew ewVar) {
        if (ewVar.getErrorCode() == 0 && ewVar.getLocationType() == 0) {
            if ("-5".equals(ewVar.d()) || "1".equals(ewVar.d()) || "2".equals(ewVar.d()) || "14".equals(ewVar.d()) || "24".equals(ewVar.d()) || "-1".equals(ewVar.d())) {
                ewVar.setLocationType(5);
            } else {
                ewVar.setLocationType(6);
            }
        }
    }

    private void d(ew ewVar) {
        if (ewVar != null) {
            this.j = ewVar;
        }
    }

    private void i() {
        if (this.n != null) {
            try {
                if (this.i == null) {
                    this.i = new AMapLocationClientOption();
                }
                this.n.a(this.i.getHttpTimeOut(), this.i.getLocationProtocol().equals(AMapLocationClientOption.AMapLocationProtocol.HTTPS), j());
            } catch (Throwable unused) {
            }
        }
    }

    private int j() {
        int i;
        if (this.i.getGeoLanguage() != null && (i = AnonymousClass1.a[this.i.getGeoLanguage().ordinal()]) != 1) {
            if (i == 2) {
                return 1;
            }
            if (i == 3) {
                return 2;
            }
        }
        return 0;
    }

    private void k() {
        boolean z;
        boolean z2;
        boolean z3;
        boolean z4;
        AMapLocationClientOption.GeoLanguage geoLanguage = AMapLocationClientOption.GeoLanguage.DEFAULT;
        boolean z5 = true;
        try {
            geoLanguage = this.i.getGeoLanguage();
            z = this.i.isNeedAddress();
            try {
                z3 = this.i.isOffset();
            } catch (Throwable unused) {
            }
        } catch (Throwable unused2) {
            z = true;
        }
        try {
            z4 = this.i.isLocationCacheEnable();
            try {
                this.t = this.i.isOnceLocationLatest();
                this.z = this.i.isSensorEnable();
                if (z3 != this.q || z != this.p || z4 != this.s || geoLanguage != this.r) {
                    s();
                }
            } catch (Throwable unused3) {
                z2 = z4;
                z5 = z3;
                boolean z6 = z2;
                z3 = z5;
                z4 = z6;
                this.q = z3;
                this.p = z;
                this.s = z4;
                this.r = geoLanguage;
            }
        } catch (Throwable unused4) {
            z5 = z3;
            z2 = true;
            boolean z62 = z2;
            z3 = z5;
            z4 = z62;
            this.q = z3;
            this.p = z;
            this.s = z4;
            this.r = geoLanguage;
        }
        this.q = z3;
        this.p = z;
        this.s = z4;
        this.r = geoLanguage;
    }

    /* JADX WARN: Removed duplicated region for block: B:42:0x001c  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0025  */
    /* JADX WARN: Removed duplicated region for block: B:55:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private void l() {
        /*
            r4 = this;
            r0 = 0
            android.content.Context r1 = r4.a     // Catch: java.lang.Throwable -> Lf
            if (r1 == 0) goto Lc
            com.loc.er$a r2 = r4.h     // Catch: java.lang.Throwable -> Lf
            if (r2 == 0) goto Lc
            r1.unregisterReceiver(r2)     // Catch: java.lang.Throwable -> Lf
        Lc:
            r4.h = r0
            goto L18
        Lf:
            r1 = move-exception
            java.lang.String r2 = "Aps"
            java.lang.String r3 = "destroy"
            com.loc.ft.a(r1, r2, r3)     // Catch: java.lang.Throwable -> L2b
            goto Lc
        L18:
            com.loc.fb r0 = r4.d
            if (r0 == 0) goto L21
            boolean r1 = r4.F
            r0.a(r1)
        L21:
            com.loc.fh r0 = r4.c
            if (r0 == 0) goto L2a
            boolean r1 = r4.F
            r0.c(r1)
        L2a:
            return
        L2b:
            r1 = move-exception
            r4.h = r0
            goto L30
        L2f:
            throw r1
        L30:
            goto L2f
        */
        throw new UnsupportedOperationException("Method not decompiled: com.loc.er.l():void");
    }

    private void m() {
        try {
            if (this.h == null) {
                this.h = new a();
            }
            if (this.G == null) {
                IntentFilter intentFilter = new IntentFilter();
                this.G = intentFilter;
                intentFilter.addAction("android.net.wifi.WIFI_STATE_CHANGED");
                this.G.addAction("android.net.wifi.SCAN_RESULTS");
            }
            this.a.registerReceiver(this.h, this.G);
        } catch (Throwable th) {
            ft.a(th, "Aps", "initBroadcastListener");
        }
    }

    private byte[] n() throws Throwable {
        if (this.l == null) {
            this.l = new fr();
        }
        if (this.i == null) {
            this.i = new AMapLocationClientOption();
        }
        if (this.d != null && this.c != null) {
            this.l.a(this.a, this.i.isNeedAddress(), this.i.isOffset(), this.d, this.c, this.b, this.C, this.O);
        }
        return this.l.a();
    }

    private boolean o() {
        return this.k == 0 || gb.b() - this.k > 20000;
    }

    private void p() {
        fh fhVar = this.c;
        if (fhVar == null) {
            return;
        }
        fhVar.a(this.m);
    }

    private boolean q() {
        fh fhVar = this.c;
        if (fhVar != null) {
            this.g = fhVar.e();
        }
        ArrayList<eg> arrayList = this.g;
        return arrayList == null || arrayList.size() <= 0;
    }

    private void r() {
        if (this.L != null) {
            this.L = null;
        }
        StringBuilder sb = this.u;
        if (sb != null) {
            sb.delete(0, sb.length());
        }
    }

    private void s() {
        try {
            fj fjVar = this.e;
            if (fjVar != null) {
                fjVar.a();
            }
            d(null);
            this.M = false;
            ev evVar = this.B;
            if (evVar != null) {
                evVar.a();
            }
        } catch (Throwable th) {
            ft.a(th, "Aps", "cleanCache");
        }
    }

    public final ew a(double d, double d2) {
        try {
            String a2 = this.n.a(this.a, d, d2);
            if (a2.contains("\"status\":\"1\"")) {
                ew a3 = this.f.a(a2);
                a3.setLatitude(d);
                a3.setLongitude(d2);
                return a3;
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }

    /* JADX WARN: Can't wrap try/catch for region: R(12:53|(1:101)(1:57)|58|(1:60)(2:88|(2:90|(1:92))(11:93|(1:97)|98|(1:100)|62|63|(2:66|(1:68)(2:69|(1:71)(2:72|(1:74)(1:75))))|76|(3:78|(1:84)(1:82)|83)|85|86))|61|62|63|(2:66|(0)(0))|76|(0)|85|86) */
    /* JADX WARN: Can't wrap try/catch for region: R(13:20|(2:22|(1:24)(1:25))|26|(2:27|28)|(8:33|34|(1:36)|38|39|(1:41)|43|(2:45|46)(2:47|(12:53|(1:101)(1:57)|58|(1:60)(2:88|(2:90|(1:92))(11:93|(1:97)|98|(1:100)|62|63|(2:66|(1:68)(2:69|(1:71)(2:72|(1:74)(1:75))))|76|(3:78|(1:84)(1:82)|83)|85|86))|61|62|63|(2:66|(0)(0))|76|(0)|85|86)(2:51|52)))|104|34|(0)|38|39|(0)|43|(0)(0)) */
    /* JADX WARN: Code restructure failed: missing block: B:154:0x00a3, code lost:
        r0 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:155:0x00a4, code lost:
        com.loc.ft.a(r0, "Aps", "getLocation getCgiListParam");
     */
    /* JADX WARN: Removed duplicated region for block: B:146:0x0085 A[Catch: all -> 0x0091, TRY_LEAVE, TryCatch #0 {all -> 0x0091, blocks: (B:137:0x006d, B:139:0x0075, B:144:0x0081, B:146:0x0085), top: B:215:0x006d }] */
    /* JADX WARN: Removed duplicated region for block: B:152:0x009b A[Catch: all -> 0x00a3, TRY_LEAVE, TryCatch #1 {all -> 0x00a3, blocks: (B:150:0x0097, B:152:0x009b), top: B:217:0x0097 }] */
    /* JADX WARN: Removed duplicated region for block: B:158:0x00b5  */
    /* JADX WARN: Removed duplicated region for block: B:160:0x00c2  */
    /* JADX WARN: Removed duplicated region for block: B:194:0x0177 A[Catch: all -> 0x0194, TryCatch #2 {all -> 0x0194, blocks: (B:189:0x0167, B:192:0x016d, B:194:0x0177, B:197:0x0181, B:200:0x018b, B:201:0x0190), top: B:219:0x0167 }] */
    /* JADX WARN: Removed duplicated region for block: B:195:0x017b  */
    /* JADX WARN: Removed duplicated region for block: B:206:0x01b0  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public final com.loc.ew a(com.loc.eq r18) throws java.lang.Throwable {
        /*
            Method dump skipped, instructions count: 482
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.loc.er.a(com.loc.eq):com.loc.ew");
    }

    public final ew a(ew ewVar) {
        this.B.a(this.s);
        return this.B.a(ewVar);
    }

    public final ew a(boolean z, eq eqVar) {
        eqVar.e(z ? "statics" : "first");
        if (this.a == null) {
            eqVar.f("#0101");
            this.o.append("context is null#0101");
            fz.a((String) null, 2011);
            return a(1, this.o.toString());
        }
        fh fhVar = this.c;
        if (fhVar != null && fhVar.n()) {
            eqVar.f("#1502");
            return a(15, "networkLocation has been mocked!#1502");
        }
        b();
        if (TextUtils.isEmpty(this.L)) {
            return a(this.x, this.o.toString());
        }
        ew b = b(z, eqVar);
        if (gb.a(b) && !Q) {
            this.e.a(this.u.toString());
            fb fbVar = this.d;
            if (fbVar != null) {
                this.e.a(fbVar.e());
            }
            d(b);
        }
        Q = true;
        return b;
    }

    public final void a() {
        fb fbVar = this.d;
        if (fbVar != null) {
            fbVar.b();
        }
    }

    public final void a(Context context) {
        try {
            if (this.a != null) {
                return;
            }
            this.B = new ev();
            Context applicationContext = context.getApplicationContext();
            this.a = applicationContext;
            gb.b(applicationContext);
            if (this.c == null) {
                this.c = new fh(this.a, (WifiManager) gb.a(this.a, "wifi"), this.N);
            }
            if (this.d == null) {
                this.d = new fb(this.a, this.N);
            }
            this.O = new fd(context, this.N);
            if (this.e == null) {
                this.e = new fj();
            }
            if (this.f == null) {
                this.f = new fq();
            }
        } catch (Throwable th) {
            th.printStackTrace();
            ft.a(th, "Aps", "initBase");
        }
    }

    public final void a(Handler handler) {
        this.N = handler;
    }

    public final void a(AMapLocation aMapLocation) {
        if (aMapLocation.getErrorCode() != 0) {
            return;
        }
        fc fcVar = new fc();
        fcVar.a = aMapLocation.getLocationType();
        fcVar.d = aMapLocation.getTime();
        fcVar.e = (int) aMapLocation.getAccuracy();
        fcVar.b = aMapLocation.getLatitude();
        fcVar.c = aMapLocation.getLongitude();
        if (aMapLocation.getLocationType() == 1) {
            this.O.a(fcVar);
        }
    }

    public final void a(AMapLocationClientOption aMapLocationClientOption) {
        this.i = aMapLocationClientOption;
        if (aMapLocationClientOption == null) {
            this.i = new AMapLocationClientOption();
        }
        fh fhVar = this.c;
        if (fhVar != null) {
            this.i.isWifiActiveScan();
            fhVar.a(this.i.isWifiScan(), this.i.isMockEnable(), AMapLocationClientOption.isOpenAlwaysScanWifi(), aMapLocationClientOption.getScanWifiInterval());
        }
        i();
        fj fjVar = this.e;
        if (fjVar != null) {
            fjVar.a(this.i);
        }
        fq fqVar = this.f;
        if (fqVar != null) {
            fqVar.a(this.i);
        }
        k();
    }

    public final void a(ew ewVar, int i) {
        if (ewVar != null && ewVar.getErrorCode() == 0) {
            fc fcVar = new fc();
            fcVar.d = ewVar.getTime();
            fcVar.e = (int) ewVar.getAccuracy();
            fcVar.b = ewVar.getLatitude();
            fcVar.c = ewVar.getLongitude();
            fcVar.a = i;
            fcVar.g = Integer.parseInt(ewVar.d());
            fcVar.h = ewVar.l();
            this.O.b(fcVar);
        }
    }

    public final void a(boolean z) {
        fb fbVar = this.d;
        if (fbVar != null) {
            fbVar.b(z);
        }
    }

    public final ew b(boolean z) {
        int i;
        String sb;
        fh fhVar = this.c;
        if (fhVar != null && fhVar.n()) {
            i = 15;
            sb = "networkLocation has been mocked!#1502";
        } else if (!TextUtils.isEmpty(this.L)) {
            ew a2 = this.e.a(this.a, this.L, this.u, true, z);
            if (gb.a(a2)) {
                d(a2);
            }
            return a2;
        } else {
            i = this.x;
            sb = this.o.toString();
        }
        return a(i, sb);
    }

    public final void b() {
        this.n = fo.a(this.a);
        i();
        if (this.b == null) {
            this.b = (ConnectivityManager) gb.a(this.a, "connectivity");
        }
        if (this.l == null) {
            this.l = new fr();
        }
    }

    public final void b(eq eqVar) {
        try {
        } catch (Throwable th) {
            ft.a(th, "Aps", "initFirstLocateParam");
        }
        if (this.v) {
            return;
        }
        r();
        if (this.t) {
            m();
        }
        fh fhVar = this.c;
        if (fhVar != null) {
            fhVar.b(this.t);
            this.g = this.c.e();
        }
        fb fbVar = this.d;
        if (fbVar != null) {
            fbVar.a(true, q());
        }
        String c = c(eqVar);
        this.L = c;
        if (!TextUtils.isEmpty(c)) {
            this.u = a(this.u);
        }
        this.v = true;
    }

    public final void b(ew ewVar) {
        if (gb.a(ewVar)) {
            this.e.a(this.L, this.u, ewVar, this.a, true);
        }
    }

    public final void c() {
        if (this.y == null) {
            this.y = new ey(this.a);
        }
        m();
        fh fhVar = this.c;
        if (fhVar != null) {
            fhVar.b(false);
            this.g = this.c.e();
        }
        fb fbVar = this.d;
        if (fbVar != null) {
            fbVar.a(false, q());
        }
        this.e.a(this.a);
        b(this.a);
        this.w = true;
    }

    public final void d() {
        if (this.o.length() > 0) {
            StringBuilder sb = this.o;
            sb.delete(0, sb.length());
        }
    }

    public final void e() {
        this.C = null;
        this.v = false;
        this.w = false;
        fj fjVar = this.e;
        if (fjVar != null) {
            fjVar.b(this.a);
        }
        ev evVar = this.B;
        if (evVar != null) {
            evVar.a();
        }
        if (this.f != null) {
            this.f = null;
        }
        fd fdVar = this.O;
        if (fdVar != null) {
            fdVar.a(this.F);
        }
        l();
        ArrayList<eg> arrayList = this.g;
        if (arrayList != null) {
            arrayList.clear();
        }
        ey eyVar = this.y;
        if (eyVar != null) {
            eyVar.f();
        }
        this.j = null;
        this.a = null;
        this.u = null;
        this.H = null;
    }

    public final void f() {
        es esVar = this.R;
        if (esVar != null) {
            esVar.d();
        }
    }

    public final void g() {
        fh fhVar;
        try {
            if (this.a == null) {
                return;
            }
            if (this.R == null) {
                this.R = new es(this.a);
            }
            fb fbVar = this.d;
            if (fbVar == null || (fhVar = this.c) == null) {
                return;
            }
            this.R.a(fbVar, fhVar, this.N);
        } catch (Throwable th) {
            av.b(th, "as", "stc");
        }
    }

    public final void h() {
        es esVar = this.R;
        if (esVar != null) {
            esVar.a();
        }
    }
}
